import VueRouter from "vue-router";
// 创建一个路由器
const router = new VueRouter({
    mode: "history", // 默认哈希路由,现在改为history路由
    // mode:'hash' 兼容性较好 一般来说使用history即可
    routes: [
        {
            path: '/',
            meta: {
                keepAlive: true,
                title: 'T_b博客'
            },
            component: () => import('../pages/Blog.vue')
        },
        {
            path: '/dynamic',
            meta: {
                title: 'T_b社区'
            },
            component: () => import('../pages/Dynamic_condition.vue')
        },
        {
            path: '/dynamic_detail',
            meta: {
                keepAlive: true,
                title: 'T_b动态详情'
            },
            component: () => import('../pages/Dynamic_detailin.vue')
        },
        {
            path: '/infomation',
            name: 'infomation',
            meta: {
                title: 'T_b个人信息'
            },
            component: () => import('../pages/Infomation.vue')
        },
    ]
})

// 后置路由守卫,在切换后和初始化时进行调用
router.afterEach((to) => {
    document.title = to.meta.title || 'Vue学习'
})

export default router